
import { useEffect, useState } from 'react';
import { getRoleList } from '@/apis/user';

function useRole() {
    const [list, setList] = useState([])
    const [loading,setLoading]=useState(true)
    const [params,setParams]=useState({
        roleName:''
    })
    // 获取角色信息
    const getList = async () => {
        let res = await getRoleList(params)
        let { code, data: _list } = res.data
        if (code == 200&&_list) {
            setList(_list.rows)
        }
        setLoading(false)
    }
    useEffect(() => {
        getList()
    }, [params])
    return {list,loading,setParams,params}
}
export { useRole }